<div id="content" class="photos">
    <?if($data->photo->src): ?>
    <h1><?=$data->TITLE?></h1>
    <div class="links nav">
        <a class="box" href="<?=$data->photo->account->url?>" title="<?=$data->photo->account->fullname?>"><?=_('Back to profile')?></a>
        <a class="box" href="/photos/album/<?=$data->photo->albumID?>" title="<?=_('Back to album')?>"><?=_('Back to album')?></a>
        <a class="box" href="/photos/photo/<?=$data->photo->prev?>" title="<?=_('Previous')?>"><?=_('Previous')?></a>
        <a class="box" href="/photos/photo/<?=$data->photo->next?>" title="<?=_('Next')?>"><?=_('Next')?></a>
    </div>
    <div class="photo">
        <div class="normal">
        <a href="/photos/photo/<?=$data->photo->next?>" title="<?=$data->photo->caption?>">
            <img src="http://<?=COOKIELESS.'/'.$data->photo->src?>" alt="<?=$data->photo->caption?>" />
        </a>
        </div>
        <p class="info">
            <span class="caption"><?=$data->photo->caption?></span>
            <span class="albumName">
                <?=_('Album')?>: <a href="/photos/album/<?=$data->photo->albumID?>" title="<?=$data->photo->name?>"><?=$data->photo->name?></a><br />
                <?=_('Owner')?>: <a href="<?=$data->photo->account->url?>" title="<?=$data->photo->account->fullname?>"><?=$data->photo->account->fullname?></a>
            </span>
            <span class="clear"></span>
        </p>
        <?if($data->photo->accountID == UID):?>
        <div class="links tool">
            <a class="box" href="javascript:del(<?=$data->photo->ID?>);" title="<?=_('Delete photo')?>"><?=_('Delete')?></a>
            <a class="box" href="/profile/photo/<?=$data->photo->ID?>" title="<?=_('Set profile photo')?>"><?=_('Set profile photo')?></a>
        </div>
        <script type="text/javascript">
        function del(ID){
                tool.confirm("<?=('Confirm')?>","<?=_('Are you sure you want to `delete` the photo?')?>",'_del(\''+ID+'\')');
        }
        function _del(ID){
                tool.post({'url':'/json/photos/delete',
                        'data':'photoID='+ID,
                        'onComplete':function(e){
                                if(e.code==200)	location.href = '<?=PREFIX?>/photos/photo/<?=$data->photo->next?>';
                                else return tool.result(400,"<?=_('Alert')?>","<?=_('Please try again later..')?>");
                        }
                });
        }
        </script>
        <?elseif(EDITOR):?>
        <div class="links tool">
            <a class="box" href="javascript:del(<?=$data->photo->ID?>);" title="<?=_('Delete')?>"><?=_('Delete')?></a>
            <?if(!$data->photo->checked):?><a class="mini" href="javascript:approve(<?=$data->photo->ID?>);" title="<?=_('Approve')?>"><?=_('Approve')?></a><?endif;?>
        </div>
        <script type="text/javascript">
        function del(ID){
            tool.confirm("<?=_('Confirm')?>","<?=_('Are you sure you want to `delete` the photo?')?>",'_del(\''+ID+'\')');
        }
        function _del(ID){
            tool.post({'url':'/json/photos/editorial,check/delete',
                'data':'photoID='+ID,
                'onComplete':function(e){
                        if(e.code==200)	location.href = '<?=PREFIX?>/photos/photo/<?=$data->photo->next?>';
                        else return tool.result(400,"<?=_('Alert')?>","<?=_('Please try again later..')?>");
                }
            });
        }
        function approve(ID){
            tool.post({'url':'/json/photos/editorial,check/approve',
                'data':'photoID='+ID,
                'onComplete':function(e){
                        if(e.code==200)	location.href = location.href;
                        else return tool.result(400,"<?=_('Alert')?>","<?=_('Please try again later..')?>");
                }
            });
        }
        </script>
        <?endif;?>
        <div class="clear"></div>
        <div id="comments">
            <?
            //$j = 0;
            if($data->postie->comments) foreach ($data->postie->comments as $i){
            //if(!$j)echo '<h1>'.$i->title.'</h1>';
            ?>
            <div class="comment <?=((++$j)%2==0)?'light':'dark'?>">
                <?
                $p = $i->sender;
                include 'apps/profile/template/mini.html';
                ?>
                <p class="commentContent">
                    <a class="senderName" href="/profile/<?=$i->sender->ID?>" title="<?=$i->sender->name?>"><?=$i->sender->name?></a>
                    <?=nl2br($i->comment)?>
                </p>
                <div class="commentDate"><?=common::date($i->date)?></div>
                <div class="clear"></div>
            </div>
            <? } ?>
        </div>
        <?if(!$data->settings->photos || $data->settings->photos->comment):?>
        <form id="form" class="commentForm" method="POST" action="/json<?=PREFIX.'/'.APP.'/'.CMD?>">
            <div class="formLineLight">
                <label class="formLabel"><?=_('Your comment')?>: </label>
                <span class="textarea"><textarea id="comment" name="comment" tabindex="1"></textarea></span>
                <span class="clear"></span>
            </div>
            <div class="formLineDark">
                <span class="submit">
                    <span id="loader" class="loader"><img src="/themes/<?=THEME?>/images/loader.gif" alt="loader" /></span>
                    <input name="PID" type="hidden" value="<?=PARAMS?>" />
                    <input id="submit" class="submit" type="submit" value="<?=_('Comment')?>" tabindex="2" />
                    <span class="clear"></span>
                </span>
            <span class="clear"></span>
            </div>
        </form>
        <?endif;?>
        <div class="clear"></div>
    </div>
    <? else:?>
        <h1><?=$data->DESCRIPTION?></h1>
        <p><?=_('The page you requested cannot be displayed at the moment. It may be temporarily unavailable, the link you clicked on may have expired, or you may not have permission to view this page.')?></p>
        <a href="/" title="<?=_('Return home')?>"><?=_('Return home')?></a>
    <? endif; ?>
<div class="clear"></div>
</div>
<div id="aside"></div>
<script type="text/javascript">tool.form();</script>